package shopping.demo.dao;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import shopping.demo.entities.Order;

import java.util.List;

@Repository
@Mapper
public interface OrderDao {
    @Select("select * from `order`")
    public List<Order> findAll();

    @Select("select * from `order` where oid=#{oid}")
    public Order findById(String oid);

    @Select("select * from `order` where uid=#{uid}")
    public List<Order> findByUserId(Long uid);

    @Select("select * from `order` where gid=#{gid}")
    public List<Order> findByGId(Integer gid);

    @Update("update `order` set status=#{status} where oid=#{oid}")
    public int changeStatus(String oid,Integer status);

    @Delete("delete from `order` where oid=#{oid}")
    public int deleteById(String oid);

    @Insert("insert into `order`(oid,time,uid,gid,count,price,status) values(#{oid},#{time},#{uid},#{gid},#{count},#{price},#{status})")
    public int createOrder(String oid, String time, Long uid, Integer gid, Integer count, Integer price,Integer status);
}
